package com.code.leetcode._202503;
/**最长公共前缀**/
public class LengestPublicPrefix {

    public static String longestCommonPrefix(String[] ss){
        String ans = "";
        if (ss.length == 0) return ans;
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            String s = ss[0];
            if (i >= s.length())return ans;
            char c = ss[0].charAt(i);
            for (String item : ss) {
                if (i >= item.length() || item.charAt(i) != c) return ans;
            }
            ans += String.valueOf(c);
        }
        return ans;
    }

}
